package cn.pid21.client.request;

import cn.pid21.client.model.PidService;
import cn.pid21.client.util.RequestUtil;
import okhttp3.Request;

/**
 * PidResolverRequest
 *
 * @author 郭志斌
 * @version 1.0.0
 * @date 2019/8/16 16:00
 */
public class PidResolverRequest implements PidRequest {

    /**
     * Handle 标识
     */
    private String pid;

    private PidResolverRequest(){}

    public static PidResolverRequest builder(){
        return new PidResolverRequest();
    }

    /**
     * 设置 pid 属性
     *
     * @param pid
     * @return PidResolverRequest
     */
    public PidResolverRequest pid(String pid){
        this.pid = pid;
        return this;
    }

    @Override
    public Request build(String clientId,String secret){
        return RequestUtil.get(RequestUtil.headers(PidRequestHeader.builder().clientId(clientId).secret(secret)),
                service().getName(),"pid",this.pid);
    }

    @Override
    public PidService service() {
        return PidService.PID_RESOLVER_SERVICE;
    }
}
